get the oid

Поиск
Список
Период
Сортировка
От Niclas Hedell
Тема get the oid
Дата
Msg-id p05200f02ba926fc45c53@[192.168.0.25]
обсуждение исходный текст
Ответы Re: get the oid  (Josh Berkus <josh@agliodbs.com>)
Re: get the oid  (Vittorio Zuccala' <vitto.z@tiscalinet.it>)
Список pgsql-novice
Hi list,

I'm not only a novice to pgsql but also to sql in general (as well as new in this list)...

Here's my question: Why doesn't the following function work?

create function getoid(name) returns integer as '
declare
        ret integer;
        tablename alias for $1;
begin
        select into ret oid from tablename;
        return ret;
end;'
language 'plpgsql';

The idea is to get the oid (or whatever) from a table given by its name as a parameter to the function. It seems that the 'from' clause can't get the right table when passing a variable with the table name. I've tried everything to get this to work (castings, subqueries, etc, etc,...)

Thanx in advance! :-)

Cheers,
Nick

В списке pgsql-novice по дате отправления:

Предыдущее
От: Joe Conway
Дата:
Сообщение: Re: Value of sequence last inserted
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: get the oid